digit_mapping = {
    'A': 10,
    'B': 11,
    'C': 12,
    'D': 13,
    'E': 14,
    'F': 15
}

def hex_to_dec(num):

    digits = num[2:]
    exp = len(digits)
    decimal = 0

    for digit in digits:
        if digit >= 'A' and digit <= 'F':
            decimal += digit_mapping[digit] * pow(16, exp - 1)
        else:
            decimal += int(digit) * pow(16, exp - 1)
        
        exp -= 1

    return decimal

print(hex_to_dec('0x1A'))